home *** CD-ROM | disk | FTP | other *** search
- ; Read a line of pixels...
-
- ; given an array of longwords and a bitmap pointer, and an y coord
- ; read an entire scanline into the array.
-
- ; a similar function for writing
-
- ; void ReadPixLine(ULONG *pixvalues, struct BitMap *bmap, WORD scanline);
- ; #pragma regcall( ReadPixLine(a0,a1,d1) )
- ; void WritePixLine(ULONG *pixvalues, struct BitMap *bmap, WORD scanline);
- ; #pragma regcall( WritePixLine(a0,a1,d1) )
-
- include 'exec/types.i'
- include 'graphics/gfx.i'
-
- xdef _ReadPixLine
- xdef _WritePixLine
-
- ; params are:
- ; a0 - longword array
- ; a1 - bitmap
- ; d1 - y
-
- SREGS reg d2/d3/d4/a2/a3/a4
-
- _ReadPixLine:
- movem.l SREGS,-(sp)
-
- moveq #0,d3 ; clear upper half d3
- move.w bm_BytesPerRow(a1),d3 ; d3 <== bytes per row
- mulu.w d3,d1 ; d1 <== plane offset
-
- moveq #0,d2
- move.b bm_Depth(a1),d2 ; d2 <== plane depth
- lea bm_Planes(a1),a3 ; a3 <== Plane pointers
- add.w d2,d2
- add.w d2,d2
- add.w d2,a3
-
- bra.s 70$
-
- 40$ moveq #0,d2 ; clear upper half d2
- move.b bm_Depth(a1),d2 ; d2 <== plane depth
- subq.w #1,d2
- move.l a3,a4 ; a4 <== Plane pointers
-
- moveq #0,d4 ; initialize pixel values to zero
- moveq #0,d5
- moveq #0,d6
- moveq #0,d7
-
- 50$ move.l -(a4),a2 ; a2 <== next bitplane pointer
- move.b (a2,d1.l),d0 ; d0 <== next pixel data word
- ; process 1st 4 bits in byte
- add.b d0,d0 ; bit 8
- addx.l d4,d4 ; into 1st pixel result
- add.b d0,d0 ; bit 7
- addx.l d5,d5 ; into 2nd pixel result
- add.b d0,d0 ; bit 6
- addx.l d6,d6 ; into 3rd pixel result
- add.b d0,d0 ; bit 5
- addx.l d7,d7 ; into 4th pixel result
-
- dbra d2,50$ ; loop to next plane
-
- movem.l d4-d7,(a0) ; move to chunk array
- lea 4*4(a0),a0
-
- moveq #0,d2 ; clear upper half d2
- move.b bm_Depth(a1),d2 ; d2 <== plane depth
- subq.w #1,d2
- move.l a3,a4 ; a4 <== Plane pointers
-
- moveq #0,d4 ; initialize pixel values to zero
- moveq #0,d5
- moveq #0,d6
- moveq #0,d7
-
- 60$ move.l -(a4),a2 ; a2 <== next bitplane pointer
- move.b (a2,d1.l),d0 ; d0 <== next pixel data word
- lsl.b #4,d0 ; shift over by 4
- ; process 2nd 4 bits in byte
- add.b d0,d0 ; bit 4
- addx.l d4,d4 ; into 5th pixel result
- add.b d0,d0 ; bit 5
- addx.l d5,d5 ; into 6th pixel result
- add.b d0,d0 ; bit 2
- addx.l d6,d6 ; into 7th pixel result
- add.b d0,d0 ; bit 1
- addx.l d7,d7 ; into 8th pixel result
-
- dbra d2,60$ ; loop to next plane
-
- movem.l d4-d7,(a0) ; move to chunk array
- lea 4*4(a0),a0
- addq #1,d1 ; next byte
-
- 70$ dbra d3,40$ ; loop to next word
-
- movem.l (sp)+,SREGS
- rts
-
- _WritePixLine:
- movem.l SREGS,-(sp)
-
- moveq #0,d3 ; clear upper half d3
- move.w bm_BytesPerRow(a1),d3 ; d3 <== bytes per row
- mulu.w d3,d1 ; d1 <== plane offset
- bra.s 70$
-
- 40$ moveq #0,d2 ; clear upper half d2
- move.b bm_Depth(a1),d2 ; d2 <== plane depth
- subq.w #1,d2
- lea bm_Planes(a1),a4 ; a4 <== Plane pointers
-
- movem.l (a0)+,d4-d7 ; move to chunk array
-
- 50$ moveq #0,d0
-
- lsr.l #1,d4
- addx.b d0,d0
- lsr.l #1,d5
- addx.b d0,d0
- lsr.l #1,d6
- addx.b d0,d0
- lsr.l #1,d7
- addx.b d0,d0
-
- lsl.w #4,d0
-
- move.l (a4)+,a2 ; a2 <== next bitplane pointer
- move.b d0,(a2,d1.l),d0 ; d0 <== next pixel data word
-
- dbra d2,50$ ; loop to next plane
-
- moveq #0,d2 ; clear upper half d2
- move.b bm_Depth(a1),d2 ; d2 <== plane depth
- subq.w #1,d2
- lea bm_Planes(a1),a4 ; a4 <== Plane pointers
-
- movem.l (a0)+,d4-d7 ; move to chunk array
-
- 60$ moveq #0,d0
-
- lsr.l #1,d4
- addx.b d0,d0
- lsr.l #1,d5
- addx.b d0,d0
- lsr.l #1,d6
- addx.b d0,d0
- lsr.l #1,d7
- addx.b d0,d0
-
- move.l (a4)+,a2 ; a2 <== next bitplane pointer
- or.b d0,(a2,d1.l),d0 ; d0 <== next pixel data word
-
- dbra d2,60$ ; loop to next plane
-
- addq #1,d1 ; next byte
- 70$ dbra d3,40$ ; loop to next word
-
- movem.l (sp)+,SREGS
- rts
-
- end
-
-
-
-
-
- SREGS equr d2-d4/a2-a5
-
- _ReadPixLine:
- movem.l SREGS,-(sp)
-
- mulu.w #bm_BytesPerRow(a1),d1 ; d1 <== plane offset
-
- moveq #0,d2 ; clear upper half d2
- move.b bm_Depth(a1),d2 ; d2 <== plane depth
- ; REM: Check for small number of planes and do special case code
-
- lea bm_Planes(a1),a5 ; a5 <== Plane pointers
-
- move.l d2,d4 ; d4 <== copy of depth
- bra.s 30$ ; start the loop
-
- moveq #1,d3 ; shift d3 from 1 to 0x8000000
-
- 10$ move.l (a5)+,a2 ; a2 <== next biplane pointer
- add.l d1,a2 ; a2 <== addr of pixel data word
-
- moveq #0,d5 ; clear upper half d5
- moveq.w bm_BytesPerRow(a1),d5 ; get bytes per row
- lsr.w #1,d5 ; d5 = numbver of words per row
-
- move.l a0,a4 ; address of longword array
- sub.l #4,a4 ; start BEFORE array
-
- bra.s 20$
-
- 12$ addq #4,a4 ; add to array pointer
- add.w d0,d0 ; move top bit into carry
- bcc 12$ ; if carry clear, then continue
-
- beq.s 13$
- add.l d3,(a4) ; else add bit into pixel val
- bra.s 12$
- 13$ add.l d3,(a4) ; else add bit into pixel val
-
- move.l a6,a4 ; and update to next row
-
- 20$ move.w (a2)+,d0 ; d0 <== next pixel data word
- move.l a4,a6 ; a6 <== lwords for this pixel wd
- add.w #16*4,a6 ; a6 <== lwords for next pixel wd
- beq.s 20$ ; if no bits set, then next plane
-
- dbra d5,12$ ; loop for next pixel data word
-
- add.l d3,d3 ; shift addition bit over 1
- 30$ dbra d4,10$
-
- movem.l (sp)+,SREGS
- rts
-
- end
-
-
-
-
-
-
- ; Read a line of pixels...
-
- ; given an array of longwords and a bitmap pointer, and an y coord
- ; read an entire scanline into the array.
-
- include 'exec/types.i'
- include 'graphics/gfx.i'
-
- ; params are:
- ; a0 - longword array
- ; a1 - bitmap
- ; d1 - y
-
- SREGS equr d2-d4/a2-a6
-
-